<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>设置</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/main.css" />
		<style>
			.mui-table-view {
				margin-top: 20px;
			}
			.mui-media-body{
				color: #515252;
				font-size: 0.2751rem;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">设置</h1>
		</header>
		<div class="mui-content">
			<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<a class="" id="">
						<div class="mui-media-body left">
							接单状态
						</div>
						<div class="mui-switch mui-switch-mini mui-active right">
							<div class="mui-switch-handle"></div>
						</div>
					</a>
				</li>
			</ul>

			<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" id="paibanbiao">
						<div class="mui-media-body">
							排班表
						</div>
					</a>

				</li>

				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" id="setting_posit">
						<div class="mui-media-body">
							服务位置
						</div>
					</a>

				</li>

				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" id="fuwuxiangmu">
						<div class="mui-media-body">
							服务项目
						</div>
					</a>

				</li>
			</ul>

			<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<a id="xiugaimima" class="mui-navigate-right">
						<div class="mui-media-body">
							修改密码
						</div>
					</a>
				</li>

				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" id="xiugaishoujihao">
						<div class="mui-media-body">
							修改手机号
						</div>
					</a>

				</li>
			</ul>
			<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<a id="service_object">
						<div class="mui-media-body">
							检查最新版本：0.0.1版本
						</div>
					</a>

				</li>
			</ul>

		</div>
	</body>
	<script type="text/javascript" src="../js/mui.min.js"></script>
	<script type="text/javascript" src="../js/xiangyingshi.js"></script>
	<script type="text/javascript" src="../js/app.js"></script>
	<script type="text/javascript" src="../js/constants.js"></script>
	<script type="text/javascript" src="../js/sharemethods.js"></script>
	<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
	<script>
		var user = localStorage.getItem("USER");
		var user = JSON.parse(user);
		mui.init({
			keyEventBind: {
				backbutton: true //打开back按键监听
			},
			beforeback: function() {
				//返回true，继续页面关闭逻辑  
				mui.back;
				return true;
			}
		});
		mui('.mui-content .mui-switch').each(function() { //循环所有toggle
			this.addEventListener('toggle', function(event) {
				var str = event.detail.isActive ? 'true' : 'false'
				
				var data = {};
				if(str == 'true') {
					data = {
						isActive: '1'
					}
				} else {
					data = {
						isActive: '0'
					}
				}
				var sussess = function(data) {
					//服务器返回响应，根据响应结果，分析是否登录成功；
					if(data.result != "success") {
						mui.toast(data.msg);
					} else {
						user.servicestatus= data.isActive
						localStorage.setItem('USER', JSON.stringify(user));
					}
				};
				commonHttpUtils(changeservicestatusUrl, "post", data, sussess, error);
			});
		});
		mui.plusReady(function() {
			if(plus.navigator.isImmersedStatusbar()) { // 兼容immersed状态栏模式
				// 获取状态栏高度并根据业务需求处理，这里重新计算了子窗口的偏移位置
				topoffset = (Math.round(plus.navigator.getStatusbarHeight()) + 45) + 'px';
				document.querySelector("header").style.height = topoffset;
				document.querySelector("header").style.paddingTop = "20px";
				document.querySelector(".mui-bar-nav~.mui-content").style.paddingTop = topoffset;
			}

			// 加载完毕后关闭等待框，并展示页面
			var currentView = plus.webview.currentWebview();
			currentView.show('slide-in-right', 200);
			plus.nativeUI.closeWaiting();
		});

		if(user.servicestatus == '0') {
			$(".mui-content .mui-switch").removeClass("mui-active");
		} else {
			$(".mui-content .mui-switch").addClass("mui-active");
		}

		document.getElementById("setting_posit").addEventListener('tap', function() {
			mui.openWindow({
				url: '../set/service_position.html',
				id: 'set/service_position.html',
				show: {
					autoShow: false, //页面loaded事件发生后自动显示，默认为true
					event: 'loaded' //页面显示时机，默认为titleUpdate事件时显示
				},
				waiting: {
					autoShow: true //自动显示等待框，默认为true
				}
			});
		});

		document.getElementById("paibanbiao").addEventListener('tap', function() {

			mui.openWindow({
				url: 'account_working_schedule.html',
				id: 'account_working_schedule.html',
				show: {
					autoShow: false, //页面loaded事件发生后自动显示，默认为true
					event: 'loaded' //页面显示时机，默认为titleUpdate事件时显示
				},
				waiting: {
					autoShow: true //自动显示等待框，默认为true
				}
			});

		});

		document.getElementById("xiugaimima").addEventListener('tap', function() {
			mui.openWindow({
				url: 'change_password.html',
				id: 'change_password.html',
				show: {
					autoShow: false, //页面loaded事件发生后自动显示，默认为true
					event: 'loaded' //页面显示时机，默认为titleUpdate事件时显示
				},
				waiting: {
					autoShow: true //自动显示等待框，默认为true
				}
			});
		});
		document.getElementById("fuwuxiangmu").addEventListener('tap', function() {
			mui.openWindow({
				url: 'set_service_Items.html',
				id: 'set_service_Items.html',
				show: {
					autoShow: false, //页面loaded事件发生后自动显示，默认为true
					event: 'loaded' //页面显示时机，默认为titleUpdate事件时显示
				},
				waiting: {
					autoShow: true //自动显示等待框，默认为true
				}
			});
		});

		document.getElementById("xiugaishoujihao").addEventListener('tap', function() {
			mui.openWindow({
				url: 'change_phone.html',
				id: 'change_phone.html',
				show: {
					autoShow: false, //页面loaded事件发生后自动显示，默认为true
					event: 'loaded' //页面显示时机，默认为titleUpdate事件时显示
				},
				waiting: {
					autoShow: true //自动显示等待框，默认为true
				}
			});
		});
	</script>

</html>